#define _CRT_SECURE_NO_WARNINGS 1
#include<stdio.h>
#include<string.h>
int main() {
	char ch[101] = { '\0' };
	int len = 0;
	int n;
	int flag[3] = { 0 };
	scanf("%d", &n);
	for (int i = 0; i < n; i++) {
		scanf("%s", ch);
		int len = strlen(ch);
		if (ch[0] != 1 && ch[0] != 2 && ch[0] != 3 && ch[0] != 4 && ch[0] != 5 && ch[0] != 6 && ch[0] != 7 && ch[0] != 8 && ch[0] != 9) {
			for (int j = 0; j < len; j++) {
				if (ch[j] >= 65 && ch[j] <= 90) {
					flag[0] = 1;
				}
				if (ch[j] >= 97 && ch[j] <= 122) {
					flag[1] = 1;
				}
				if (ch[j] >= 48 && ch[j] <= 57) {
					flag[2] = 1;
				}
				if (flag[0] + flag[1] + flag[2] == 0) {
					break;
				}
			}
		}
		else printf("NO\n");
		if (flag[0] + flag[1] + flag[2] < 2 || len < 8) {
			printf("NO\n");
		}
		else printf("YES\n");
	}
	return 0;
}